<template>
  <el-dialog v-model="visible" title="金币">
    <el-form>
      <el-form-item label="金币数量">
        <el-input-number :min="1" :max="10000000" v-model="goldNum"></el-input-number>
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button type="primary" @click="sendGoldApi">确认</el-button>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { sendGold } from "@/api/modules/broker";
import { ElMessage } from "element-plus";

const goldNum = ref(1);

const nowId = ref(0);

const getTable = ref<() => Promise<any>>();

const visible = ref(false);

const acceptParams = (params: any) => {
  nowId.value = params.id;
  getTable.value = params.getTable;
  visible.value = true;
};

const sendGoldApi = async () => {
  try {
    await sendGold({ id: nowId.value, num: goldNum.value });
    ElMessage.success("成功");
    await getTable.value!();
    visible.value = false;
  } catch (error) {}
};

defineExpose({ acceptParams });
</script>

<style></style>
